home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / util / shell / axuucp_0_1.lha / axsh / rexx / rn-list.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1995-03-22  |  2.4 KB  |  97 lines

  1. /****** axuucp/rn-list *******************************************************
  2. *
  3. *   NAME
  4. *    rn-list - List available AXsh Newsgroups
  5. *
  6. *   SYNOPSIS
  7. *    rx rn-list.rexx [trailer]
  8. *
  9. *   DESCRIPTION
  10. *    This script scans the AXsh:usr/spool/news hierarchy and reports all
  11. *    existing Newsgroups.  It can be used to create the NewsGroups file
  12. *    automatically.  The optional trailer will be printed behind the
  13. *    name of each group, seperated by a space.
  14. *
  15. *   EXAMPLE
  16. *    Create the NewsGroups file with an expire time of 60 days for each
  17. *    group:
  18. *
  19. *    % rx rn-list.rexx 60 > AXsh:usr/spool/news/NewsGroups
  20. *
  21. *   AUTHOR
  22. *    Tobias Ferber <tf@ganymed.hall.sub.org>
  23. *
  24. ******************************************************************************
  25. *
  26. */
  27.  
  28. axnews = axconfig("news")
  29. tempfile = "t:rn-list." || pragma('Id')
  30.  
  31. /**/
  32.  
  33. cwd = pragma('D',axnews)
  34. address command 'list all dirs lformat "%p%n" >' tempfile
  35. address command 'sort from' tempfile 'to' tempfile
  36. call pragma('D',cwd)
  37.  
  38. call open('fp',tempfile)
  39. g=readln('fp')
  40.  
  41. do until eof('fp')
  42.   s= readln('fp')
  43.   if ~abbrev(s,g) then say translate(g,'.','/') arg(1)
  44.   g=s
  45.   end
  46.  
  47. call close('fp')
  48. address command 'delete quiet' tempfile
  49. exit
  50.  
  51.  
  52. /*@<axconfig>*/
  53.  
  54. /* get an AXsh configuration value */
  55.  
  56. axconfig: procedure
  57.   tempfile = "T:axconfig." || pragma('Id')
  58.   rc_index  = "AXsh:rexx/rc.index"
  59.   var_val=""; var_file=""; var_defval="";
  60.  
  61.   parse upper arg var_name
  62.   if left(var_name,1) ~= '%' then var_name = '%'var_name
  63.   if right(var_name,1) ~= ':' then var_name = var_name':'
  64.  
  65.   if open('idx',rc_index,'Read') then do
  66.     do until (eof('idx') | (var_file~=''))
  67.       str= translate(readln('idx'),' ',d2c(9))
  68.       if words(str) > 0 then do
  69.         parse var str vname ' ' fname '"' defval '"'
  70.         if upper(vname) = var_name then do
  71.           var_file= strip(fname,'B',' 'd2c(9))
  72.           var_defval= defval
  73.           end
  74.         end
  75.       end
  76.     call close('idx')
  77.     end
  78.   else say 'Could not read "'rc_index'"'
  79.  
  80.   if words(var_file) > 0 then do
  81.     if open('rc',var_file,'Read') then do
  82.       do until (eof('rc') | (var_val~=''))
  83.         str= translate(readln('rc'),' ',d2c(9))
  84.         if upper(word(str,1)) = var_name then var_val = strip(readln('rc'),'B',' 'd2c(9))
  85.         end
  86.       call close('rc')
  87.       end
  88.     else say 'Could not examine "'var_file'" for' var_name
  89.     end
  90.   else do
  91.     if words(var_defval) > 0 then var_val= var_defval
  92.     else say 'No such config variable:' var_name
  93.     end
  94.  
  95.   return var_val
  96.  
  97.